package com.way.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Knife4jConfig {

    @Bean
    public GroupedOpenApi authApi() {
        return GroupedOpenApi.builder()
                .group("auth-service")
                .pathsToMatch("/auth/**")
                .build();
    }

    @Bean
    public GroupedOpenApi demoApi() {
        return GroupedOpenApi.builder()
                .group("demo-service")
                .pathsToMatch("/demo/**")
                .build();
    }

    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI().info(new Info()
                .title("way系统API")
                .description("Knife4j集成springdoc-openapi示例")
                .version("1.0")
                .contact(new Contact().name("陆翔")));
    }

//
//    @Bean
//    public OpenAPI customOpenAPI() {
//        return new OpenAPI()
//                .components(new Components()
//                        .addSecuritySchemes("api", new SecurityScheme().type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name("X-Hearder-For"))
//                        .addSecuritySchemes("token", new SecurityScheme().type(SecurityScheme.Type.APIKEY).in(SecurityScheme.In.HEADER).name("Token")))
////                .addSecurityItem(new SecurityRequirement().addList("a", "a1"))
//                .info(info());
//    }
//
//    //    @Bean
//    public SecurityScheme securityScheme() {
//        return new SecurityScheme()
//                .type(SecurityScheme.Type.APIKEY)
//                .in(SecurityScheme.In.HEADER);
//    }
//
//    @Bean
//    public Info info() {
//        return new Info()
//                .title("接口文档")
//                .description("系统的接口文档描述")
//                .version("1.0")
//                .contact(new Contact().name("陆翔"));
//    }

}
